import os

from library_test.mock_manage.mock_model.mock_ansible_module import AnsibleModule
from library_test.test_install_dl.test_install_dl import TestInstallDl


class TestNpuExporter(TestInstallDl):
    NPU_EXPORTER_MODULE = "ascend_deployer.library.install_npu_exporter"

    @classmethod
    def setUpClass(cls) -> None:
        super().setUpClass()

    @classmethod
    def get_module_path(cls):
        return "ascend_deployer.library.install_npu_exporter"

    @classmethod
    def get_testcase_path(cls):
        return os.path.join(cls.TESTCASE_DIR, "arch64_install_npu_exporter_success.yml")

    def test(self):
        from ascend_deployer.library.install_npu_exporter import NpuExporterInstaller
        with self.assertRaises(AnsibleModule.ExitJson) as context:
            NpuExporterInstaller().run()
        res = self.parse_context_exception(context)
        self.assertIn("successfully", res.get("msg"))

    @classmethod
    def tearDownClass(cls) -> None:
        super().tearDownClass()